<include file="Common/header" />
<script type="text/javascript" src="__PUBLIC__/uploadify/jquery.uploadify.min.js"></script>
<link rel="stylesheet" href="__PUBLIC__/uploadify/uploadify.css" >
<div class="container">
    <div class="row">

            <include file="Common/left_siber" />

        <div class="col-md-10" >
            <form action="{:U('Article/savehandler')}" method="post">
                <input type="hidden" name="aid" value="{$articles['aid']}">
                <script type="text/javascript"   src="__PUBLIC__/ueditor/ueditor.config.js"></script>
                <script type="text/javascript"    src="__PUBLIC__/ueditor/ueditor.all.js"></script>
                <script type="text/javascript"    src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
                <div class="row">

                    <div class="page-header"><h3>{$page_title}</h3></div>
                    <div class="col-md-8" style="padding: 0;">

                        <div class="btn-group  role="group" aria-label="" style="margin-bottom:10px;" >
                        <a  class="btn btn-default <if condition="CONTROLLER_NAME eq 'Article' && ACTION_NAME eq 'index'">active</if>" href="{:U('Article/index')}">所有文章</a>&nbsp;
                        <a  class="btn btn-default <if condition="CONTROLLER_NAME eq 'Article' && ACTION_NAME eq 'add'">active</if>" href="{:U('Article/add')}" style="margin-bottom:10px;"> 添加文章</a>
                    </div>

                    <div class="form-group">
                        <input type="text" class="form-control"  placeholder=" 题目" name="title" value="{$articles['title']}">
                    </div>
                    <div class="form-group">
                        <select class="form-control" name="category_cid">
                            <option value="0">选择类</option>
                            <foreach  name="category" item="c">

                                <option value="{$c['id']}"  <if condition="$articles['category_cid'] eq $c['id']">selected</if>>
                                    <if condition="$c['pid'] neq 0"><?php echo str_repeat('&nbsp',$c['level']*8); ?></if>{$c['cname']}</option>

                            </foreach>

                        </select>
                    </div>
                    <div class="form-group" >
                        <textarea class="form-control" name="description" rows="6"  placeholder=" 简介内容 ">{$articles['description']}</textarea>
                    </div>

                    <div class="form-group" >
                        <textarea name="content" id="editor"  style="height:400px;width: 100%;" placeholder="内容">{$articles['content']}</textarea>
                        <script>
                            var ue = UE.getEditor('editor');
                        </script>
                    </div>

                    <div class="form-group">
                        <input type="text" class="form-control"  placeholder="排序" name="sort" value="{$articles['sort']}">
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control"  placeholder="作者 " name="author" value="{$articles['author']}">
                    </div>
                    <div class="radio">
                        <label class="radio-inline">
                            <input type="radio" name="status"  value="1" <if condition="$articles['status']==1">checked</if>> 开启
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="status"  value="0" <if condition="$articles['status']==0">checked</if>> 关闭
                        </label>
                    </div>
                    <button type="submit" class="btn btn-primary">保存</button>

                </div>
                <div class="col-md-4">
                    <div class="panel panel-default">
                        <div class="panel-heading"> 封面</div>
                        <div class="panel-body">
                            <span value="time()" name="add_time"></span>
                            <input type="text" class="form-control" id="thumb" name="thumb" value="{$articles['thumb']}">
                            <input id="file" type="file" multiple="false">
                            <br>
                            <img src="/{$articles['thumb']}" alt="" id="thumber" >
                            <script type="text/javascript">
                                $(function() {
                                    $('#file').uploadify({
                                        'formData'     : {
                                            '<?php echo session_name();?>' : '<?php echo session_id();?>',
                                        },
                                        'fileTypeDesc' : '上传文件',//上传描述
                                        'fileTypeExts' : '*.jpg;*.png',
                                        'swf' : '__PUBLIC__/uploadify/uploadify.swf',
                                        'uploader' : "{:U('Article/uploadThumb')}",
                                        'buttonText':'选择文件',
                                        'fileSizeLimit' : '2000KB',
                                        'uploadLimit' : 1,//上传文件数
                                        'width':65,
                                        'height':25,
                                        'successTimeout':10,//等待服务器响应时间
                                        'removeTimeout' : 0.2,//成功显示时间
                                        'onUploadSuccess' : function(file, data, response) {
                                            //转为json
                                            data=$.parseJSON(data);
                                            $('#thumb').val(data);
                                            $('#thumber').attr('src','/'+data);
                                            //获得图片地址
                                            //console.log(data);
                                            /*var imageUrl = data.url;
                                             var li="<li path='"+data.path+"' url='"+data.url+"'><img src='"+imageUrl+"'/><input type='hidden' name='thumb' value='"+data.path+"'/></li>";
                                             $("#uploadList ul").prepend(li);*/
                                        }
                                    });
                                });
                            </script>
                            <div id="uploadList">
                            <ul>

                            </ul>
                        </div>
                        </div>
                    </div>

                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title">所有标签</h3>
                        </div>
                        <div class="panel-body">
                            <foreach name="tags" item="t">
                                <label class="checkbox-inline">  <input type="checkbox"  value="{$t['tid']}" name="tag[]"
                                    <if condition="in_array($t['tid'],$article_tag)">checked</if> > {$t['tname']} </label>
                            </foreach>

                        </div>
                    </div>
                </div>
        </div>
        </form>
    </div>

</div>
</div>
<include file="Common/footer" />